{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--BOOK_INFORMATION-->\n",
    "<a href=\"https://user-images.githubusercontent.com/19553554/71825144-2d568180-30d6-11ea-8ee0-63c849cfd934.png\" target=\"_blank\"><img align=\"left\" style=\"width: 76px; height: 100px; background: white; padding: 1px; border: 1px solid black; margin-right:10px;\"></a>\n",
    "*pyecharts 是一个用于生成 Echarts 图表的类库。Echarts 是百度开源的一个数据可视化 JS 库。用 Echarts 生成的图可视化效果非常棒，为了与 Python 进行对接，方便在 Python 中直接使用数据生成图，于是有人开发出了这个项目[GitHub](https://github.com/pyecharts/pyecharts) .*\n",
    "\n",
    "*Note.建议本程序在参看https://github.com/pyecharts/pyecharts 的安装步骤后再运行； 本程序所有的例子都是从官方提供的样例代码[GitHub](https://github.com/pyecharts/pyecharts-gallery)中提取的,如果对某个API有疑问建议在IDE里面查看*\n",
    "\n",
    "*Echart类型图种大全:https://echarts.apache.org/examples/zh/#chart-type-line pyecharts图导入到ppt中的方法:https://baijiahao.baidu.com/s?id=1663839456876951842&wfr=spider&for=pc.*\n",
    "\n",
    "*作者: LBQ; 时间:2020/7/24. 邮箱:779660843@qq.com*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# XXIV.桑基能量分流图(sankey)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"8171d8001e8a42b38d3faee5c484fea6\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_8171d8001e8a42b38d3faee5c484fea6 = echarts.init(\n",
       "                    document.getElementById('8171d8001e8a42b38d3faee5c484fea6'), 'white', {renderer: 'canvas'});\n",
       "                var option_8171d8001e8a42b38d3faee5c484fea6 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"sankey\",\n",
       "            \"name\": \"sankey\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"category1\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"category2\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"category3\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"category4\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"category5\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"category6\"\n",
       "                }\n",
       "            ],\n",
       "            \"links\": [\n",
       "                {\n",
       "                    \"source\": \"category1\",\n",
       "                    \"target\": \"category2\",\n",
       "                    \"value\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"category2\",\n",
       "                    \"target\": \"category3\",\n",
       "                    \"value\": 15\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"category3\",\n",
       "                    \"target\": \"category4\",\n",
       "                    \"value\": 20\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"category5\",\n",
       "                    \"target\": \"category6\",\n",
       "                    \"value\": 25\n",
       "                }\n",
       "            ],\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"5%\",\n",
       "            \"right\": \"20%\",\n",
       "            \"bottom\": \"5%\",\n",
       "            \"nodeWidth\": 20,\n",
       "            \"nodeGap\": 8,\n",
       "            \"nodeAlign\": \"justify\",\n",
       "            \"layoutIteration\": 32,\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"draggable\": true,\n",
       "            \"focusNodeAdjacency\": false,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 0.2,\n",
       "                \"curveness\": 0.5,\n",
       "                \"type\": \"solid\",\n",
       "                \"color\": \"source\"\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"sankey\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"sankey\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Sankey-\\u57fa\\u672c\\u793a\\u4f8b\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_8171d8001e8a42b38d3faee5c484fea6.setOption(option_8171d8001e8a42b38d3faee5c484fea6);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f6be4c346d8>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Sankey\n",
    "\n",
    "nodes = [\n",
    "    {\"name\": \"category1\"},\n",
    "    {\"name\": \"category2\"},\n",
    "    {\"name\": \"category3\"},\n",
    "    {\"name\": \"category4\"},\n",
    "    {\"name\": \"category5\"},\n",
    "    {\"name\": \"category6\"},\n",
    "]\n",
    "\n",
    "links = [\n",
    "    {\"source\": \"category1\", \"target\": \"category2\", \"value\": 10},\n",
    "    {\"source\": \"category2\", \"target\": \"category3\", \"value\": 15},\n",
    "    {\"source\": \"category3\", \"target\": \"category4\", \"value\": 20},\n",
    "    {\"source\": \"category5\", \"target\": \"category6\", \"value\": 25},\n",
    "]\n",
    "c = (\n",
    "    Sankey()\n",
    "    .add(\n",
    "        \"sankey\",\n",
    "        nodes,\n",
    "        links,\n",
    "        linestyle_opt=opts.LineStyleOpts(opacity=0.2, curve=0.5, color=\"source\"),\n",
    "        label_opts=opts.LabelOpts(position=\"right\"),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Sankey-基本示例\"))\n",
    "  #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c.load_javascript()\n",
    "c.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"9a76c35b5eb247dc96c4348de71a1e26\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_9a76c35b5eb247dc96c4348de71a1e26 = echarts.init(\n",
       "                    document.getElementById('9a76c35b5eb247dc96c4348de71a1e26'), 'white', {renderer: 'canvas'});\n",
       "                var option_9a76c35b5eb247dc96c4348de71a1e26 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"sankey\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Agricultural 'waste'\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Bio-conversion\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Liquid\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Losses\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Solid\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Gas\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Biofuel imports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Biomass imports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Coal imports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Coal\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Coal reserves\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"District heating\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Industry\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Heating and cooling - commercial\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Heating and cooling - homes\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Electricity grid\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Over generation / exports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"H2 conversion\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Road transport\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Agriculture\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Rail transport\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Lighting & appliances - commercial\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Lighting & appliances - homes\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Gas imports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Ngas\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Gas reserves\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Thermal generation\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Geothermal\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"H2\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Hydro\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"International shipping\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Domestic aviation\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"International aviation\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"National navigation\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Marine algae\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Nuclear\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Oil imports\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Oil\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Oil reserves\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Other waste\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Pumped heat\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Solar PV\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Solar Thermal\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Solar\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Tidal\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"UK land based bioenergy\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Wave\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Wind\"\n",
       "                }\n",
       "            ],\n",
       "            \"links\": [\n",
       "                {\n",
       "                    \"source\": \"Agricultural 'waste'\",\n",
       "                    \"target\": \"Bio-conversion\",\n",
       "                    \"value\": 124.729\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Bio-conversion\",\n",
       "                    \"target\": \"Liquid\",\n",
       "                    \"value\": 0.597\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Bio-conversion\",\n",
       "                    \"target\": \"Losses\",\n",
       "                    \"value\": 26.862\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Bio-conversion\",\n",
       "                    \"target\": \"Solid\",\n",
       "                    \"value\": 280.322\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Bio-conversion\",\n",
       "                    \"target\": \"Gas\",\n",
       "                    \"value\": 81.144\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Biofuel imports\",\n",
       "                    \"target\": \"Liquid\",\n",
       "                    \"value\": 35\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Biomass imports\",\n",
       "                    \"target\": \"Solid\",\n",
       "                    \"value\": 35\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Coal imports\",\n",
       "                    \"target\": \"Coal\",\n",
       "                    \"value\": 11.606\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Coal reserves\",\n",
       "                    \"target\": \"Coal\",\n",
       "                    \"value\": 63.965\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Coal\",\n",
       "                    \"target\": \"Solid\",\n",
       "                    \"value\": 75.571\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"District heating\",\n",
       "                    \"target\": \"Industry\",\n",
       "                    \"value\": 10.639\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"District heating\",\n",
       "                    \"target\": \"Heating and cooling - commercial\",\n",
       "                    \"value\": 22.505\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"District heating\",\n",
       "                    \"target\": \"Heating and cooling - homes\",\n",
       "                    \"value\": 46.184\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Over generation / exports\",\n",
       "                    \"value\": 104.453\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Heating and cooling - homes\",\n",
       "                    \"value\": 113.726\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"H2 conversion\",\n",
       "                    \"value\": 27.14\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Industry\",\n",
       "                    \"value\": 342.165\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Road transport\",\n",
       "                    \"value\": 37.797\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Agriculture\",\n",
       "                    \"value\": 4.412\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Heating and cooling - commercial\",\n",
       "                    \"value\": 40.858\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Losses\",\n",
       "                    \"value\": 56.691\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Rail transport\",\n",
       "                    \"value\": 7.863\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Lighting & appliances - commercial\",\n",
       "                    \"value\": 90.008\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Electricity grid\",\n",
       "                    \"target\": \"Lighting & appliances - homes\",\n",
       "                    \"value\": 93.494\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas imports\",\n",
       "                    \"target\": \"Ngas\",\n",
       "                    \"value\": 40.719\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas reserves\",\n",
       "                    \"target\": \"Ngas\",\n",
       "                    \"value\": 82.233\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas\",\n",
       "                    \"target\": \"Heating and cooling - commercial\",\n",
       "                    \"value\": 0.129\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas\",\n",
       "                    \"target\": \"Losses\",\n",
       "                    \"value\": 1.401\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas\",\n",
       "                    \"target\": \"Thermal generation\",\n",
       "                    \"value\": 151.891\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas\",\n",
       "                    \"target\": \"Agriculture\",\n",
       "                    \"value\": 2.096\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Gas\",\n",
       "                    \"target\": \"Industry\",\n",
       "                    \"value\": 48.58\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Geothermal\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 7.013\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"H2 conversion\",\n",
       "                    \"target\": \"H2\",\n",
       "                    \"value\": 20.897\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"H2 conversion\",\n",
       "                    \"target\": \"Losses\",\n",
       "                    \"value\": 6.242\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"H2\",\n",
       "                    \"target\": \"Road transport\",\n",
       "                    \"value\": 20.897\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Hydro\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 6.995\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"Industry\",\n",
       "                    \"value\": 121.066\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"International shipping\",\n",
       "                    \"value\": 128.69\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"Road transport\",\n",
       "                    \"value\": 135.835\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"Domestic aviation\",\n",
       "                    \"value\": 14.458\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"International aviation\",\n",
       "                    \"value\": 206.267\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"Agriculture\",\n",
       "                    \"value\": 3.64\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"National navigation\",\n",
       "                    \"value\": 33.218\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Liquid\",\n",
       "                    \"target\": \"Rail transport\",\n",
       "                    \"value\": 4.413\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Marine algae\",\n",
       "                    \"target\": \"Bio-conversion\",\n",
       "                    \"value\": 4.375\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Ngas\",\n",
       "                    \"target\": \"Gas\",\n",
       "                    \"value\": 122.952\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Nuclear\",\n",
       "                    \"target\": \"Thermal generation\",\n",
       "                    \"value\": 839.978\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Oil imports\",\n",
       "                    \"target\": \"Oil\",\n",
       "                    \"value\": 504.287\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Oil reserves\",\n",
       "                    \"target\": \"Oil\",\n",
       "                    \"value\": 107.703\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Oil\",\n",
       "                    \"target\": \"Liquid\",\n",
       "                    \"value\": 611.99\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Other waste\",\n",
       "                    \"target\": \"Solid\",\n",
       "                    \"value\": 56.587\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Other waste\",\n",
       "                    \"target\": \"Bio-conversion\",\n",
       "                    \"value\": 77.81\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Pumped heat\",\n",
       "                    \"target\": \"Heating and cooling - homes\",\n",
       "                    \"value\": 193.026\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Pumped heat\",\n",
       "                    \"target\": \"Heating and cooling - commercial\",\n",
       "                    \"value\": 70.672\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solar PV\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 59.901\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solar Thermal\",\n",
       "                    \"target\": \"Heating and cooling - homes\",\n",
       "                    \"value\": 19.263\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solar\",\n",
       "                    \"target\": \"Solar Thermal\",\n",
       "                    \"value\": 19.263\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solar\",\n",
       "                    \"target\": \"Solar PV\",\n",
       "                    \"value\": 59.901\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solid\",\n",
       "                    \"target\": \"Agriculture\",\n",
       "                    \"value\": 0.882\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solid\",\n",
       "                    \"target\": \"Thermal generation\",\n",
       "                    \"value\": 400.12\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Solid\",\n",
       "                    \"target\": \"Industry\",\n",
       "                    \"value\": 46.477\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Thermal generation\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 525.531\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Thermal generation\",\n",
       "                    \"target\": \"Losses\",\n",
       "                    \"value\": 787.129\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Thermal generation\",\n",
       "                    \"target\": \"District heating\",\n",
       "                    \"value\": 79.329\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Tidal\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 9.452\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"UK land based bioenergy\",\n",
       "                    \"target\": \"Bio-conversion\",\n",
       "                    \"value\": 182.01\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Wave\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 19.013\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Wind\",\n",
       "                    \"target\": \"Electricity grid\",\n",
       "                    \"value\": 289.366\n",
       "                }\n",
       "            ],\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"5%\",\n",
       "            \"right\": \"20%\",\n",
       "            \"bottom\": \"5%\",\n",
       "            \"nodeWidth\": 20,\n",
       "            \"nodeGap\": 8,\n",
       "            \"nodeAlign\": \"justify\",\n",
       "            \"layoutIteration\": 32,\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"draggable\": true,\n",
       "            \"focusNodeAdjacency\": false,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 0.5,\n",
       "                \"curveness\": 0.5,\n",
       "                \"type\": \"solid\",\n",
       "                \"color\": \"source\"\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#aaa\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Sankey Diagram\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_9a76c35b5eb247dc96c4348de71a1e26.setOption(option_9a76c35b5eb247dc96c4348de71a1e26);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f6bcf1026d8>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import asyncio\n",
    "#from aiohttp import TCPConnector, ClientSession\n",
    "import json\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Sankey\n",
    "\n",
    "\"\"\"\n",
    "Gallery 使用 pyecharts 1.1.0\n",
    "参考地址: https://echarts.baidu.com/examples/editor.html?c=sankey-energy\n",
    "\n",
    "目前无法实现的功能:\n",
    "\n",
    "1、label 和图的层次有点问题\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "# async def get_json_data(url: str) -> dict:\n",
    "#     async with ClientSession(connector=TCPConnector(ssl=False)) as session:\n",
    "#         async with session.get(url=url) as response:\n",
    "#             return await response.json()\n",
    "\n",
    "\n",
    "# # 获取官方的数据\n",
    "# data = asyncio.run(\n",
    "#     get_json_data(url=\"https://echarts.baidu.com/examples/data/asset/data/energy.json\")\n",
    "# )\n",
    "with open(\"energy.json\", \"r\", encoding=\"utf-8\") as f:\n",
    "    data = json.load(f)\n",
    "\n",
    "c2 = (\n",
    "    Sankey()\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        nodes=data[\"nodes\"],\n",
    "        links=data[\"links\"],\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_width=1, border_color=\"#aaa\"),\n",
    "        linestyle_opt=opts.LineStyleOpts(color=\"source\", curve=0.5, opacity=0.5),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger_on=\"mousemove\"),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Sankey Diagram\"))\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c2.load_javascript()\n",
    "c2.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"1cf511101d4842e0b6d3f55709bf59c7\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_1cf511101d4842e0b6d3f55709bf59c7 = echarts.init(\n",
       "                    document.getElementById('1cf511101d4842e0b6d3f55709bf59c7'), 'white', {renderer: 'canvas'});\n",
       "                var option_1cf511101d4842e0b6d3f55709bf59c7 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#67001f\",\n",
       "        \"#b2182b\",\n",
       "        \"#d6604d\",\n",
       "        \"#f4a582\",\n",
       "        \"#fddbc7\",\n",
       "        \"#d1e5f0\",\n",
       "        \"#92c5de\",\n",
       "        \"#4393c3\",\n",
       "        \"#2166ac\",\n",
       "        \"#053061\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"sankey\",\n",
       "            \"name\": \"sankey\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"a\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"b\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"a1\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"b1\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"c\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"e\"\n",
       "                }\n",
       "            ],\n",
       "            \"links\": [\n",
       "                {\n",
       "                    \"source\": \"a\",\n",
       "                    \"target\": \"a1\",\n",
       "                    \"value\": 5\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"e\",\n",
       "                    \"target\": \"b\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"a\",\n",
       "                    \"target\": \"b1\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"b1\",\n",
       "                    \"target\": \"a1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"b1\",\n",
       "                    \"target\": \"c\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"b\",\n",
       "                    \"target\": \"c\",\n",
       "                    \"value\": 1\n",
       "                }\n",
       "            ],\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"5%\",\n",
       "            \"right\": \"20%\",\n",
       "            \"bottom\": \"10%\",\n",
       "            \"nodeWidth\": 20,\n",
       "            \"nodeGap\": 8,\n",
       "            \"nodeAlign\": \"justify\",\n",
       "            \"layoutIteration\": 32,\n",
       "            \"orient\": \"vertical\",\n",
       "            \"draggable\": true,\n",
       "            \"focusNodeAdjacency\": \"allEdges\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 0.2,\n",
       "                \"curveness\": 0.5,\n",
       "                \"type\": \"solid\",\n",
       "                \"color\": \"source\"\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"sankey\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"sankey\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Sankey-Vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_1cf511101d4842e0b6d3f55709bf59c7.setOption(option_1cf511101d4842e0b6d3f55709bf59c7);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f6bcf130f60>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Sankey\n",
    "\n",
    "colors = [\n",
    "    \"#67001f\",\n",
    "    \"#b2182b\",\n",
    "    \"#d6604d\",\n",
    "    \"#f4a582\",\n",
    "    \"#fddbc7\",\n",
    "    \"#d1e5f0\",\n",
    "    \"#92c5de\",\n",
    "    \"#4393c3\",\n",
    "    \"#2166ac\",\n",
    "    \"#053061\",\n",
    "]\n",
    "nodes = [\n",
    "    {\"name\": \"a\"},\n",
    "    {\"name\": \"b\"},\n",
    "    {\"name\": \"a1\"},\n",
    "    {\"name\": \"b1\"},\n",
    "    {\"name\": \"c\"},\n",
    "    {\"name\": \"e\"},\n",
    "]\n",
    "links = [\n",
    "    {\"source\": \"a\", \"target\": \"a1\", \"value\": 5},\n",
    "    {\"source\": \"e\", \"target\": \"b\", \"value\": 3},\n",
    "    {\"source\": \"a\", \"target\": \"b1\", \"value\": 3},\n",
    "    {\"source\": \"b1\", \"target\": \"a1\", \"value\": 1},\n",
    "    {\"source\": \"b1\", \"target\": \"c\", \"value\": 2},\n",
    "    {\"source\": \"b\", \"target\": \"c\", \"value\": 1},\n",
    "]\n",
    "c3 = (\n",
    "    Sankey()\n",
    "    .set_colors(colors)\n",
    "    .add(\n",
    "        \"sankey\",\n",
    "        nodes=nodes,\n",
    "        links=links,\n",
    "        pos_bottom=\"10%\",\n",
    "        focus_node_adjacency=\"allEdges\",\n",
    "        orient=\"vertical\",\n",
    "        linestyle_opt=opts.LineStyleOpts(opacity=0.2, curve=0.5, color=\"source\"),\n",
    "        label_opts=opts.LabelOpts(position=\"top\"),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Sankey-Vertical\"),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", trigger_on=\"mousemove\"),\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c3.load_javascript()\n",
    "c3.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"3665425c521a4560aa1d37eaa825d62b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_3665425c521a4560aa1d37eaa825d62b = echarts.init(\n",
       "                    document.getElementById('3665425c521a4560aa1d37eaa825d62b'), 'white', {renderer: 'canvas'});\n",
       "                var option_3665425c521a4560aa1d37eaa825d62b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"sankey\",\n",
       "            \"name\": \"sankey\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Total\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Environment\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Land use\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Cocoa butter (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Cocoa mass (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Hazelnuts (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Cane sugar (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Vegetables (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Climate change\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Harmful substances\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Water use\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Resource depletion\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Refrigeration\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Packaging\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Human rights\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Child labour\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Coconut oil (Organic)\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Forced labour\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Health safety\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Access to water\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Freedom of association\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Access to land\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Sufficient wage\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Equal rights migrants\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Discrimination\"\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Working hours\"\n",
       "                }\n",
       "            ],\n",
       "            \"links\": [\n",
       "                {\n",
       "                    \"source\": \"Total\",\n",
       "                    \"target\": \"Environment\",\n",
       "                    \"value\": 0.342284047256003\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Land use\",\n",
       "                    \"value\": 0.32322870366987\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Land use\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.177682517071359\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Land use\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.137241325342711\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Land use\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.00433076373512774\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Land use\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00296956039863467\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Land use\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00100453712203756\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Climate change\",\n",
       "                    \"value\": 0.0112886157414413\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Climate change\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.00676852971933996\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Climate change\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00394686874786743\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Climate change\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.000315972058711838\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Climate change\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.000218969462265292\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Climate change\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 3.82757532567656e-05\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Harmful substances\",\n",
       "                    \"value\": 0.00604275542495656\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Harmful substances\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.0055125989240741\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Harmful substances\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.000330017607892127\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Harmful substances\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.000200138892990337\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Harmful substances\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Harmful substances\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Water use\",\n",
       "                    \"value\": 0.00148345269044703\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Water use\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.00135309891304186\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Water use\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.000105714137908639\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Water use\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 1.33452642581887e-05\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Water use\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 8.78074837009238e-06\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Water use\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 2.5136268682477e-06\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Resource depletion\",\n",
       "                    \"value\": 0.000240519729288764\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Resource depletion\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.000226237279345084\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Resource depletion\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 1.42824499436793e-05\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Resource depletion\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Resource depletion\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Resource depletion\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Refrigeration\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Environment\",\n",
       "                    \"target\": \"Packaging\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Total\",\n",
       "                    \"target\": \"Human rights\",\n",
       "                    \"value\": 0.307574096993239\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Child labour\",\n",
       "                    \"value\": 0.0410641202645833\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0105339381639722\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.0105\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0087294420777\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00474399974233333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00388226450884445\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Child labour\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00267447577173333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Forced labour\",\n",
       "                    \"value\": 0.0365458590642445\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0114913076376389\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0081134807347\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00765230236575\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.004\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00296668823626667\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Forced labour\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00232208008988889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Health safety\",\n",
       "                    \"value\": 0.0345435327843611\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0121419536385\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00766772850678333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0056245892061\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00361616847688889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00277374682533333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Health safety\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00271934613075556\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Access to water\",\n",
       "                    \"value\": 0.0340206659360667\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.0105\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0089274160792\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0054148022845\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00333938149786667\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00314663377488889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to water\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00269243229961111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Freedom of association\",\n",
       "                    \"value\": 0.0320571523941667\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0132312483463611\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0077695200707\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00510606573995\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00354321156324444\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00240710667391111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Freedom of association\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Access to land\",\n",
       "                    \"value\": 0.0315022209894056\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.00964970063322223\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00938530207965\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0060110791848\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00380818314608889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00264795594564445\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Access to land\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Sufficient wage\",\n",
       "                    \"value\": 0.0287776757227333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00883512456493333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0078343367268\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00347879026511111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.00316254211388889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00281013722808889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Sufficient wage\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00265674482391111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Equal rights migrants\",\n",
       "                    \"value\": 0.0271146645119444\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0071042315061\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00636673210005\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.00601459775836111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00429185583138889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00182647471915556\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Equal rights migrants\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00151077259688889\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Discrimination\",\n",
       "                    \"value\": 0.0211217763359833\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00609671700306667\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0047738806325\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00368119084494444\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00286009813604444\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.00283706180951111\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Discrimination\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.000872827909916666\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Human rights\",\n",
       "                    \"target\": \"Working hours\",\n",
       "                    \"value\": 0.02082642898975\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Hazelnuts (Organic)\",\n",
       "                    \"value\": 0.0107216773848333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Coconut oil (Organic)\",\n",
       "                    \"value\": 0.00359009052944444\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Vegetables (Organic)\",\n",
       "                    \"value\": 0.00212300379075556\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Cocoa butter (Organic)\",\n",
       "                    \"value\": 0.0018518584356\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Cocoa mass (Organic)\",\n",
       "                    \"value\": 0.00158227069058333\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Working hours\",\n",
       "                    \"target\": \"Cane sugar (Organic)\",\n",
       "                    \"value\": 0.000957528158533333\n",
       "                }\n",
       "            ],\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"10%\",\n",
       "            \"right\": \"20%\",\n",
       "            \"bottom\": \"5%\",\n",
       "            \"nodeWidth\": 20,\n",
       "            \"nodeGap\": 8,\n",
       "            \"nodeAlign\": \"justify\",\n",
       "            \"layoutIteration\": 32,\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"draggable\": true,\n",
       "            \"focusNodeAdjacency\": true,\n",
       "            \"levels\": [\n",
       "                {\n",
       "                    \"depth\": 0,\n",
       "                    \"itemStyle\": {\n",
       "                        \"color\": \"#fbb4ae\"\n",
       "                    },\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 0.6,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\",\n",
       "                        \"color\": \"source\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"depth\": 1,\n",
       "                    \"itemStyle\": {\n",
       "                        \"color\": \"#b3cde3\"\n",
       "                    },\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 0.6,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\",\n",
       "                        \"color\": \"source\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"depth\": 2,\n",
       "                    \"itemStyle\": {\n",
       "                        \"color\": \"#ccebc5\"\n",
       "                    },\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 0.6,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\",\n",
       "                        \"color\": \"source\"\n",
       "                    }\n",
       "                },\n",
       "                {\n",
       "                    \"depth\": 3,\n",
       "                    \"itemStyle\": {\n",
       "                        \"color\": \"#decbe4\"\n",
       "                    },\n",
       "                    \"lineStyle\": {\n",
       "                        \"show\": true,\n",
       "                        \"width\": 1,\n",
       "                        \"opacity\": 0.6,\n",
       "                        \"curveness\": 0,\n",
       "                        \"type\": \"solid\",\n",
       "                        \"color\": \"source\"\n",
       "                    }\n",
       "                }\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0.5,\n",
       "                \"type\": \"solid\"\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"sankey\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"sankey\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Sankey-Level Settings\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_3665425c521a4560aa1d37eaa825d62b.setOption(option_3665425c521a4560aa1d37eaa825d62b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f6bcf0db550>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Sankey\n",
    "\n",
    "with open(\"product.json\", \"r\", encoding=\"utf-8\") as f:\n",
    "    j = json.load(f)\n",
    "c4 = (\n",
    "    Sankey()\n",
    "    .add(\n",
    "        \"sankey\",\n",
    "        nodes=j[\"nodes\"],\n",
    "        links=j[\"links\"],\n",
    "        pos_top=\"10%\",\n",
    "        focus_node_adjacency=True,\n",
    "        levels=[\n",
    "            opts.SankeyLevelsOpts(\n",
    "                depth=0,\n",
    "                itemstyle_opts=opts.ItemStyleOpts(color=\"#fbb4ae\"),\n",
    "                linestyle_opts=opts.LineStyleOpts(color=\"source\", opacity=0.6),\n",
    "            ),\n",
    "            opts.SankeyLevelsOpts(\n",
    "                depth=1,\n",
    "                itemstyle_opts=opts.ItemStyleOpts(color=\"#b3cde3\"),\n",
    "                linestyle_opts=opts.LineStyleOpts(color=\"source\", opacity=0.6),\n",
    "            ),\n",
    "            opts.SankeyLevelsOpts(\n",
    "                depth=2,\n",
    "                itemstyle_opts=opts.ItemStyleOpts(color=\"#ccebc5\"),\n",
    "                linestyle_opts=opts.LineStyleOpts(color=\"source\", opacity=0.6),\n",
    "            ),\n",
    "            opts.SankeyLevelsOpts(\n",
    "                depth=3,\n",
    "                itemstyle_opts=opts.ItemStyleOpts(color=\"#decbe4\"),\n",
    "                linestyle_opts=opts.LineStyleOpts(color=\"source\", opacity=0.6),\n",
    "            ),\n",
    "        ],\n",
    "        linestyle_opt=opts.LineStyleOpts(curve=0.5),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Sankey-Level Settings\"),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", trigger_on=\"mousemove\"),\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c4.load_javascript()\n",
    "c4.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
